package com.gdip.mapper;


import com.gdip.po.ProblemPo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface ProblemMapper {

    int insertProblem(ProblemPo problem);

    List<ProblemPo> selectProblemsByUserId(@Param("userId") int userId);

    // 修改
    int updateProblem(ProblemPo problemPo);

    // 按status查询问题
    List<ProblemPo> getProblemAll_returnStatus(@Param("status") String status);

    // 根据部门id查所有问题id
    List<ProblemPo> getProblemIdByClassId(@Param("classId") int classId);

    // 问题分类统计-根据问题类型id查询对应问题记录，返回用户id，部门id,创建时间，解决状态
    List<ProblemPo> getProblemByTypeId(@Param("typeId") int typeId);

    List<ProblemPo> selectProblemsByUserIdAndStatus(@Param("userId") int userId, @Param("status") String status);

    List<ProblemPo> selectProblemsByClassIdAndStatus(@Param("classId") int classId, @Param("status") String status);

    ProblemPo findById(@Param("id") int id);

    @Select("<script>" +
            "SELECT * FROM problem " +
            "<where> " +
            "   <if test='title != null'> AND title LIKE CONCAT('%', #{title}, '%')</if> " +

            "</where>" +
            "</script>")
    List<ProblemPo> selectProblemsByTitleAndCreateTime(@Param("title") String title);

}
